package com.ck567.springboot.kafka.controller;


import com.ck567.springboot.kafka.demo.KafkaProducer;
import com.ck567.springboot.kafka.model.Person;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ww
 * @date 2020/9/29 上午10:49
 */
@Slf4j
@RestController
public class KafkaController {

    @Autowired
    private KafkaProducer kafkaProducer;

    @GetMapping("/sendMsg")
    public void sendMsg(){
        Person p0 = new Person("黄帝","男",5002,"山西");
        Person p1 = new Person("黄帝","男",5002,"山西");
        Person p2 = new Person("黄帝","男",5002,"山西");
        Person p3 = new Person("黄帝","男",5002,"山西");
        Person p4 = new Person("黄帝","男",5002,"山西");
        Person p5 = new Person("黄帝","男",5002,"山西");
        Person p6 = new Person("黄帝","男",5002,"山西");

        List l = new ArrayList<>();
        l.add(p0);
        l.add(p1);
        l.add(p2);
        l.add(p3);
        l.add(p4);
        l.add(p5);
        l.add(p6);

        kafkaProducer.send(l);
    }
}
